/*
 * @Author: funlee
 * @Email: i@funlee.cn
 * @Date: 2019-06-27 10:30:21
 * @Description: 首页-应用工具-企业信息检索
 */
import { observable, action } from "mobx";
import resource from "@/utils/resource";
import API from "@/utils/api";

class EnterpriseInformationRetrievalStore {
    @observable keyWords = "";
    @observable resultListData = { count: 0, lists: [] }; // 搜索结果页-列表
    @observable resultCurrentPage = 1; // 搜索结果页-列表分页
    @observable detailId = ""; // 详情页目标对象的 id

    @action.bound
    changeKeyWords(keyWords) {
        this.keyWords = keyWords;
    }

    @action.bound
    getResultListData() {
        resource
            .get(API.homeEIRResultLists, {
                page: this.resultCurrentPage,
                keyWords: this.keyWords
            })
            .then(res => {
                this.resultListData = res;
            });
    }

    @action.bound
    setDetailId(id) {
        this.detailId = id;
    }

    @action.bound
    changePage(newPage) {
        this.currentPage = newPage;
        this.getResultListData();
    }
}

export default new EnterpriseInformationRetrievalStore();
